package com.aimo.base.exceptiondemo.controller;

import com.aimo.base.exceptiondemo.core.BizException;
import com.aimo.base.exceptiondemo.http.HttpResult;
import com.aimo.base.exceptiondemo.http.HttpStatus;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: lmy
 * @Date: 2021/2/19 14:15
 * @Description:
 */
@Slf4j
@RestController
public class TestController {

    @GetMapping(value="/test/{code}")
    public HttpResult test(@PathVariable("code") int code, Model model) {
        log.info("userId:{}", model.getAttribute("userId"));
        if (code == 1) {
            throw new BizException(HttpStatus.ERROR_PARAM);
        }
        return HttpResult.ok();
    }
}
